import Vue from 'vue';
import VueRouter from 'vue-router';
import Login from '@/components/UserLogin.vue';
import TeacherHome from '@/components/TeacherHome.vue';
import StudentHome from '@/components/StudentHome.vue';
import TeacherCourse from "@/views/TeacherCourse/TeacherCourse.vue";
import SearchSubject from '@/views/ModifyGrades/SearchSubject.vue';
import SearchStudent from '@/views/ModifyGrades/SearchStudent.vue';
import TeacherSchedule from '@/views/Resources/TeacherSchedule.vue';
import ClassSchedule from '@/views/Resources/ClassSchedule.vue';
import StudentInfo from '@/views/ManagerPerson/StudentInfo.vue';
import ModifyInfo from '@/views/ManagerPerson/ModifyInfo.vue';
import YiTest from '@/views/ManagerTest/YiTest.vue';
import UnTest from '@/views/ManagerTest/UnTest.vue';

Vue.use(VueRouter);

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: "/teacher",
    redirect: "/teacher/course",
    name: 'TeacherHomeRedirect',
  },
  {
    path: "/teacher",
    name: 'TeacherHome',
    component: TeacherHome,
    meta: { requiresAuth: true, role: 'teacher' },
    children: [
      {
        name: "course",
        path: "course",
        component: TeacherCourse
      },
      {
        name: "subject",
        path: "subject",
        component: SearchSubject
      },
      {
        name: "SearchStudent",
        path: "SearchStudent",
        component: SearchStudent
      },
    ]
  },
  {
    path: '/student',
    name: 'StudentHome',
    component: StudentHome,
    meta: { requiresAuth: true, role: 'student' },
    children: [
      {
        name: "studentcourse",
        path: "studentcourse",
        component: TeacherSchedule, 
      },
      {
        name: "schedule",
        path: "schedule",
        component: ClassSchedule
      },
      {
        name: "studentInfo",
        path: "studentInfo",
        component: StudentInfo
      },
      {
        name: "modifyInfo",
        path: "modifyInfo",
        component: ModifyInfo
      },
      {
        name: "Yitest",
        path: "yitest",
        component: YiTest
      },
      {
        name: "UnTest",
        path: "untest",
        component: UnTest
      },
    ]
  },
  {
    path: '*',
    redirect: '/login'
  }
];

const router = new VueRouter({
  routes
});
//导出路由
export default router;